#coding=utf-8
'''
Created on 2016年3月2日
'''
__author__ = 'chenjian'

import zmq  
  
context = zmq.Context()  
  
#  Socket to talk to server  
print "Connecting to hello world server..."  
socket = context.socket(zmq.REQ)  
socket.connect ("tcp://192.168.0.2:5555")  
  
#  Do 10 requests, waiting each time for a response  
for request in range (1,10):  
    print "Sending request ", request,"..."  
    socket.send ("Hello")  
      
    #  Get the reply.  
    message = socket.recv()  
    print "Received reply ", request, "[", message, "]"  